** -----------------------------------------------------------------------------
** REPLICATION CODE
** Chiappori, Costa Dias, Meghir and Zhang, 'Changes in Marital Sorting: Theory 
** and Evidence from the US', Journal of Political Economy, 2025
** Master file: builds dataset and replicates all estimates in the paper.
** -----------------------------------------------------------------------------


** Set directories
** Fill with path to locations

	global datafolder ""	/// data 
	global dofolder   ""	/// replication code
	global logfolder  ""	/// log files
	
** Prepare data
	
	do "$dofolder\1. CPS data.do"

** Calculate sorting matrices and bootstrap 

	do "$dofolder\2. sorting matrices.do"

** Table 2: sorting matrices

	mat list Smx50, f(%3.1f)
	mat list Smx70, f(%3.1f)
	
** Calculate Indices and test statistics for changes in assortativeness

	do "$dofolder\3. indices of assortativeness & test stats.do"
	
** Test changes in assortativeness correcting for multiple testing using 
** the stepdown method
** Print Tables 3 and Table 5 (in Online Appendix)

	do "$dofolder\4. test changes in assortativeness.do"
	
** Test changes in assortativeness using generalized indices
** Print Table 4

	do "$dofolder\5. generalised structural indices.do"
	


	

	



